﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.Apply>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	申请修改数据详情
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        RoleEnum role = (RoleEnum)ViewData["role"];
    %>
    <% using (Html.BeginForm("Process", "Modification", FormMethod.Post, new { id = "processForm" }))
    {%>
        <%= Html.ValidationSummary(true) %>
        <%= Html.HiddenFor(model => model.Id) %>
        <%= Html.Hidden("Action") %>
            
    <table class="tableCss" cellspacing="0" cellpadding="0" align="center" border="0" style="margin-top:10px">
        <tr>
            <th colspan="2" class="heightrow" align="left" style="padding:10px">
                申请修改数据详情
            </th>
        </tr>
        <tr>
           <td class="row1" align="center">所属公司</td>
           <td class="row1" align="left"><%=Model.FactoryName %></td>
        </tr>
        <tr>
           <td class="row1" align="center">申请人</td>
           <td class="row1" align="left"><%=Model.Applier %></td>
        </tr>
        <tr>
           <td class="row1" align="center">申请类型</td>
           <td class="row1" align="left">
                <input type="radio" name="type" disabled="disabled" <%if (Model.type == 1){ %>checked="checked"<%} %> value="1" id="simple" onclick="applySimpleChange();" />申请修改少量历史数据
                <input type="radio" name="type" disabled="disabled" <%if (Model.type == 2){ %>checked="checked"<%} %> value="2" id="missed" onclick="applyMissedChange();" style="margin-left:20px" />申请历史数据的补录
           </td>
        </tr>
        <tr>
           <td class="row1" align="center" valign="top">处理状态</td>
           <td class="row1" align="left">
                <%=(Model.Status)%>
           </td>
        </tr>
        <%if (Model.Status == "已拒绝"){ %>
        <tr>
           <td class="row1" align="center" valign="top">拒绝原因</td>
           <td class="row1" align="left">
                <%= Html.DisplayFor(model => model.Reason)%>
           </td>
        </tr>
        <%} %>
        <tr>
           <td class="row1" align="center" valign="top">申请标题</td>
           <td class="row1" align="left">
                <%= Html.DisplayFor(model => model.Title)%>
           </td>
        </tr>
        <tr>
           <td class="row1" align="center" valign="top">申请内容</td>
           <td class="row1" align="left">
                <%= Html.TextAreaFor(model => model.Content, new { disabled="disabled", cols=50, rows=10, id="content"})%>
           </td>
        </tr>
        <tr id="missedFile" <%if (Model.type == 1){ %>style="display:none"<%} %>>
           <td class="row1" align="center" valign="top">补录数据</td>
           <td class="row1" align="left">
                <%if(!string.IsNullOrEmpty(Model.File)) {%><a href="<%=Url.Content(Model.File) %>" target="_blank">查看附件</a><%} %>
           </td>
        </tr>
        <%
            if (Model.Status == "等待审批")
            {
        %>
        <tr>
           <td class="row1" align="center" valign="top">拒绝原因</td>
           <td class="row1" align="left">
                <%= Html.TextAreaFor(model => model.Reason, new { rows = 5, cols = 50 })%>
           </td>
        </tr>
        <%
            }
        %>
    </table>
    
    <div style="margin-top:25px;text-align:center">
        <%if (role == RoleEnum.Auditor && Model.Status == "等待审批") { %>
        <input type="button" value="批    准" onclick="approve();" style="font-size:16px;font-weight:bold" />
        <input type="button" value="拒    绝" onclick="reject();" style="font-size:16px;font-weight:bold" />
        <%}
          else if (role == RoleEnum.Administrator && Model.Status == "已批准")
          {%>
        <input type="button" value="修改数据" onclick="process();" style="font-size:16px;font-weight:bold" />
        <input type="button" value="完    成" onclick="finish();" style="font-size:16px;font-weight:bold" />
        <%} %>
    </div>
    <% } %>

    <script type="text/javascript" language="javascript">
        function process() {
            window.open('<%=Url.Content("~/Modification/SelectFactory") %>');
        }
        
        function approve() {
            $("#Action").val("approve");
            $("#processForm").submit();
        }

        function reject() {
            var reason = document.getElementById("Reason").value;
            if (reason == null || reason == "" || reason == undefined) {
                alert("请填写拒绝原因。");
                document.getElementById("Reason").focus();
                return;
            }
            $("#Action").val("reject");
            $("#processForm").submit();
        }

        function finish() {
            $("#Action").val("finish");
            $("#processForm").submit();
        }
    </script>
</asp:Content>

